<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<c:if test="${sessionMother==null}">
<div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
        	<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          
          <a class="brand" href="${ctx}/action/homeAction">宝贝秀</a>
          
	          <div class="nav-collapse">
	            <ul class="nav nav-pills">
	              <li class="active"><a href="${ctx}/action/homeAction">首页</a></li>
	              <c:forEach items="${catalogList}" var="catalog">
					<li id="${catalog.id}"><a href="#" >${catalog.name}</a></li>
					</c:forEach>	             
	            </ul>        
	           
					  <form class="navbar-form form-inline pull-right">
				    <div class="input-prepend">
				    <span class="add-on"><i class="icon-envelope"></i></span>
				    <input type="text" id='email' class="input-small" placeholder="邮件">
				    </div>
				     <div class="input-prepend">
				    <span class="add-on"><i class="icon-lock"></i></span>
				    <input type="password" id='password' class="input-small" placeholder="密码">
				    </div>
				    <label class="checkbox">
				    <input type="checkbox"> 记住我
				    </label>
				   
				    <button type="button" class="btn btn-info" onclick="login()">登录</button>
				    <a class="btn btn-warning" href="${ctx}/action/forwardRegister">注册</a>
				    </form>
				   
	          </div><!--/.nav-collapse -->
	          
        </div>
        
		

      </div>
    </div>
    </c:if>
<!--登录成功后的显示信息  -->
<c:if test="${sessionMother!=null}">
<div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid">
        	<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          
          <a class="brand" href="${ctx}/action/homeAction">宝贝秀</a>
          
	          <div class="nav-collapse">
	            <div class="nav-collapse">
	            <ul class="nav nav-pills">
	              <li class="active"><a href="${ctx}/action/homeAction">首页</a></li>
	              <c:forEach items="${catalogList}" var="catalog">
					<li id="${catalog.id}"><a href="#" >${catalog.name}</a></li>
					</c:forEach>	             
	            </ul>        
	               <div class='pull-right'>欢迎<a  href='${ctx}/action/editMother'>${sessionMother.name}</a>回来</div>
				   
	          </div><!--/.nav-collapse -->
	          
        </div>
      </div>
    </div>
</c:if>
<!--end-->
    <div class="modal hide fade" id='message'>
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>信息</h3>
    </div>
    <div class="modal-body">
    <p></p>
    </div>  
    </div>
<script type="text/javascript">
function login(){
	$.ajax({
		url:"${ctx}/action/login",
		data:"email="+$('#email').val()+"&password="+$('#password').val(),
		method:"POST",
		dataType:"json",
		success:function(data){
			 if(data.flag){
				 window.location.reload();
				 parent.window.location="${ctx}/action/homeAction";
				 }
			 else{
				 $('.modal-body').html(data.message);
				 $('#message').modal('show');
				 $('body').oneTime('2s',function(){ 
					 $('#message').modal('hidden');
					}); 
					 				
				 }
			}
		});
}
</script>
